#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    string addStrings(string num1, string num2) {
        string ret;
        int num1i = 0;
        int num2i = 0;
        int carry = 0;
        int n1 = 0;
        int n2 = 0;
        while (num1i < num1.size() || num2i < num2.size())
        {
            n1 = num1i < num1.size() ? num1[num1.size() - num1i - 1] - '0' : 0;
            n2 = num2i < num2.size() ? num2[num2.size() - num2i - 1] - '0' : 0;

            ret += (n1 + n2 + carry) % 10 + '0';
            carry = (n1 + n2 + carry) / 10;
            num1i++;
            num2i++;
        }
        if (carry)
        {
            ret += '1';
        }

        reverse(ret.begin(), ret.end());
        return ret;
    }
};

int main()
{
    string s;
    Solution d;
    s = d.addStrings("11", "123");
    cout << s << endl;
    return 0;
}